home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-16 | 21.5 KB | 773 lines | [TEXT/KAHL] |
- /* Library of functions for doing things to dialogs and to items in
- the dialogs. Makes using dialogs somewhat simpler. There are also
- several macros (defined in the header for this library) which handle
- special cases for the functions in this library.
-
- Revision History:
-
- 93/12/24 aih
- - added functions for setting/getting a floating point value to/from a
- text field
-
- 93/11/16 aih
- - if in pre-7.0 system and using a movable modal dialog then
- a special WDEF (released by MacDTS) is substituted for WDEF 0.
- - improved dialog creation code
-
- 93/11/07 aih
- - removed a lot of unneeded and unused code
-
- 93/11/05 aih
- - a text record is created for each edit text field, which simplifies
- event handling
-
- 93/10/16 aih
- - added a couple of assertions
- - fixed redraw with SetIText in windows whose kind field was not dialogKind
-
- 93/03/19 AIH
- - Removed call to AlertFake when a dialog couldn't be loaded since
- this duplicated certain alerts (such as the out of memory alert)
- - Removed library initialization function
-
- 93/03/17 AIH
- - Tab keys always select the current edit field (tabs in dialogs
- with multiple fields are handled elsewhere)
- - Item's rectangle is erased before calling SetIText, so that text
- is drawn correctly
-
- 93/03/16 AIH
- - Changed DlgWithin to return only control and edit text items, since
- these are the only item types which respond to user actions (i.e.,
- mouse clicks and keyboard input)
-
- 93/03/06 AIH
- - Menu commands are disable if memory is low
-
- 93/03/05 AIH
- - Added WinHide
-
- 92/03/02 AIH
- - Changed extra window data into a pointer which is saved in
- the window's refCon field. This simplified a lot of the code.
- Thanks goodness for data hiding! It made modifying this
- library a breeze.
-
- 92/02/27 AIH
- - TE cut, copy, paste, and clear functions are used instead
- of the corresponding "Dlg" functions, since the Dialog Manager
- functions didn't seem to use the same scrap as the rest of the
- application and system when copying text.
-
- 92/02/20 AIH
- - Dialogs are registered with the event library
- - Simplifying event handling
-
- 91/11/15 AIH
- - Removed knowledge of dialog color tables when creating dialogs
- or alerts.
-
- 91/11/14 AIH
- - Removed checks for system software version 7.0
-
- 91/07/08 AIH
- - The apple menu is only disabled when running as an application
- and a modal dialog is created
-
- 91/06/01 AIH
- - After a dialog is created its window rectangles are initialized to its
- default position by calling WinRectSet
- - A color dialog is created if color is supported on the Macintosh,
- and the 'dctb' or 'actb' resources are loaded and installed as described
- in IM-V.
-
- 91/05/12 AIH
- - Added state and size fields to dialog record
-
- 91/05/10 AIH
- - Can create a dialog using either an 'ALRT' or a 'DLOG' template
-
- 91/05/07 AIH
- - When a dialog is created the cursor is only set to an arrow if not
- running as an application; this avoids confusing cursors, especially
- when the dialog is being displayed as an indication of a lengthy
- procedure
- - The DlgType... macros are used instead of testing the type directly;
- this is easier to write, debug, and maintain
-
- 91/04/26 AIH
- - Dialog positioning is handled by window library, so code for doing it
- was removed from this file
-
- 91/04/24 AIH
- - Added data field to dialog, for use by the application
-
- 91/04/19 AIH
- - The Apple menu is disabled when a modal dialog is created so that
- system 7.0 will know that we handle menu disabling
-
- 91/04/17 AIH
- - The current port is *not* set after a dialog is created
- - Added functions for getting and setting the dialog's default item
- - Added functions for accessing the current edit text field
-
- 91/04/09 AIH
- - The dialog is hidden just before it is disposed of to avoid unnecessary
- drawing
- - An alert is displayed if the dialog couldn't be loaded
- - Improved error detection and paid particular attention to purgeable
- resources
-
- 91/04/07 AIH
- - Added ability to preload a set of dialogs
-
- 91/04/03 AIH
- - Added a few fields to the dialog structure
-
- 91/03/31 AIH
- - Eliminated need for menus mask
-
- 91/03/24-25 AIH
- - Adapted for international canceling
- - Extended keyboard function keys are now recognized for dialog editing
- - Split modal dialog functions into a separate file
- - Dialogs are allocated by calling NewPtr
-
- 91/03/23 AIH
- - When positioning a window, its default size should be used if
- it doesn't entirely fit on the default screen. This requires scanning the
- GDevice list and I don't have any way to debug this without a newer
- Macintosh and multiple monitors.
- - Adapted for new way of quitting the event loop
-
- 91/03/20 AIH
- - Instead of redrawing the default control when a window receives an
- activate event, we invalidate its region, and let the update event
- handle the drawing. This should avoid an annoying flicker when the
- control is drawn twice when the window is activated and then receives
- an update event.
-
- 91/03/19 AIH
- - Modified initialization function to take a mask indicating which
- menus can be disabled when a modal dialog is displayed
-
- 91/03/17 AIH
- - Removed "Get" sub-word from title of most dialog functions
- - Event library is only used to run modal dialogs if compiling as an
- application
-
- 91/03/14 AIH
- - Added function to query modal dialogs for last item hit
-
- 91/03/12 AIH
- - If the procID of the dialog is 5, and if running in a pre-7.0 system, then
- the procID is changed to use the movable modal WDEF distributed by MacDTS.
-
- 91/03/10-11 AIH
- - Adapted modal dialog functions to use my event library, so that
- there will only be one event loop in the entire application
- - Added application settable flag indicating whether this library can
- affect the menu bar when running a modal dialog
- - Added function to return the number of items in a dialog
-
- 91/03/02-07 AIH
- - The standard dialog filter function sets the current graf port
- to the dialog's graf port. This is needed by DialogSelect.
- - Added function to draw the outline of the default button in gray
- - The standard dialog filter will not interpret command keys
- (cut, copy, paste) if we're running system 7.0
- - My replacement for ModalDialog will call WNE with a sleep interval
- of 0 if the dialog received an event the last time WNE was called. This
- will allow the filter procedure to get at least a null event immediately
- after it got the previous event, in case it needs to update the dialog
- depending on what the user last did. For instance, if the ok button
- can only be activated if there's text in a field, then the filter
- procedure needs to activate the button *after* DialogSelect has
- been called by my replacement to ModalDialog.
- - Extra parameters to ParamText are passed as NULL pointers instead
- of empty strings (IM-1, p421 says it's ok to do this)
- - The default button is drawn on activate events. This takes advantage of my
- default button CDEF
-
- 91/02/27-28 AIH
- - Added function to frame a user item
- - Cursor is set to arrow when a dialog is created
-
- 91/02/05 AIH
- - system windows are recognized as valid dialogs by DlgValid
- - DlgModalRun calls EventNext and DlgModalEvent instead of
- ModalDialog. This will give me more control over modal dialogs
- and will give background applications more time.
-
- 91/02/03 AIH
- - Removed DlgModalRunOnce since I can't figure out a good way to write
- it. Made DlgModalRun use ModalDialog, since there's no advantage to using
- my functions and since I know ModalDialog works. Someday maybe I'll replace
- ModalDialog, but not today.
-
- 91/01/31 AIH
- - added functions to replace the standard ModalDialog
-
- 91/01/21 AIH
- - added brief comment describing this file
- - simplified call to DlgParamText
- - added use of DlgErrSetup
-
- 91/01/19 AIH
- - added support for escape key
-
- 91/01/05 Ari Halberstadt (AIH)
- - inserted this standard header in all files */
-
- #include <string.h>
- #include <stdlib.h>
- #include <TextEdit.h>
- #include "pstr.h"
- #include "ControlLib.h"
- #include "DialogLib.h"
- #include "DialogModalLib.h"
- #include "DrawLib.h"
- #include "EventLib.h"
- #include "FloatLib.h"
- #include "GlobalLib.h"
- #include "KeyLib.h"
- #include "LowMemLib.h"
- #include "MacLib.h"
- #include "MemoryLib.h"
- #include "RectangleLib.h"
- #include "ResourceConstantsLib.h"
- #include "ResourceLib.h"
- #include "StringLib.h"
- #include "TextLib.h"
- #include "WindowLib.h"
- #include "MenuLib.h"
-
- /* List of preloaded dialogs. This list is searched whenever Dlg is called. If the dialog's ID is in the list, and if the dialog
- isn't already open, then a pointer to the preloaded dialog is
- returned. Otherwise, the dialog is created from scratch. This feature
- is primarily useful for error alerts, which may be displayed in response
- to such things as out-of-memory and resource manager errors. In such
- cases, it would be impractical to display an error message which requires
- a significant amount of memory or which needs resources. */
- static struct {
- Boolean open; /* true if dialog is already open */
- DialogPtr dlg; /* pointer to dialog */
- ResType type; /* type of dialog ('DLOG' or 'ALRT') */
- short id; /* id of dialog */
- } gPreload[DLG_PRELOAD_MAX];
-
- /* true if dialog is valid */
- Boolean DlgValid(DialogPtr dlg)
- {
- return(dlg && WinIsDialog(dlg));
- }
-
- /* return number of items in the dialog */
- short DlgNItems(DialogPtr dlg)
- {
- require(DlgValid(dlg));
- return((*(short *) *((DialogPeek)dlg)->items) + 1);
- }
-
- /* true if a valid item in the dialog */
- Boolean DlgItemValid(DialogPtr dlg, short item)
- {
- return(0 < item && item <= DlgNItems(dlg));
- }
-
- /*----------------------------------------------------------------------------*/
- /* getting dialog items */
- /*----------------------------------------------------------------------------*/
-
- /* return the type of the item */
- short DlgType(DialogPtr dlg, short item)
- {
- short type;
- Handle hndl;
- Rect box;
-
- require(DlgValid(dlg));
- require(DlgItemValid(dlg, item));
- GetDItem(dlg, item, &type, &hndl, &box);
- return(type);
- }
-
- /* return the handle to the item */
- Handle DlgHandle(DialogPtr dlg, short item)
- {
- short type;
- Handle hndl;
- Rect box;
-
- require(DlgValid(dlg));
- require(DlgItemValid(dlg, item));
- GetDItem(dlg, item, &type, &hndl, &box);
- return(hndl);
- }
-
- /* get the item's box */
- void DlgBox(DialogPtr dlg, short item, Rect *box)
- {
- short type;
- Handle hndl;
-
- require(DlgValid(dlg));
- require(DlgItemValid(dlg, item));
- GetDItem(dlg, item, &type, &hndl, box);
- }
-
- /*----------------------------------------------------------------------------*/
- /* default item functions */
- /*----------------------------------------------------------------------------*/
-
- /* return the default item */
- short DlgDefault(DialogPtr dlg)
- {
- require(DlgValid(dlg));
- return(((DialogPeek)dlg)->aDefItem);
- }
-
- /* set the default item */
- void DlgDefaultSet(DialogPtr dlg, short item)
- {
- require(DlgValid(dlg));
- require(! item || DlgItemValid(dlg, item));
-
- /* erase and invalidate the old frame */
- if (DlgItemValid(dlg, DlgDefault(dlg)))
- if (DlgTypeCtl(DlgType(dlg, DlgDefault(dlg))))
- CtlDefaultErase(DlgCtl(dlg, DlgDefault(dlg)));
-
- /* set the new default item */
- ((DialogPeek)dlg)->aDefItem = item;
-
- /* erase and invalidate the new frame */
- if (DlgItemValid(dlg, DlgDefault(dlg)))
- if (DlgTypeCtl(DlgType(dlg, DlgDefault(dlg))))
- CtlDefaultErase(DlgCtl(dlg, DlgDefault(dlg)));
- }
-
- /* frame the default button */
- void DlgDefaultFrame(DialogPtr dlg, Pattern pat)
- {
- if (DlgItemValid(dlg, DlgDefault(dlg)))
- if (DlgTypeCtl(DlgType(dlg, DlgDefault(dlg))))
- CtlDefaultFrame(DlgCtl(dlg, DlgDefault(dlg)), pat);
- }
-
- /*----------------------------------------------------------------------------*/
- /* static and edit text item functions */
- /*----------------------------------------------------------------------------*/
-
- static TextHandle DlgTextHandle(DialogPtr dlg, short item)
- {
- TextHandle text = NULL;
-
- require(DlgTypeText(DlgType(dlg, item)));
- if (WinHasExtra(dlg))
- text = WinRegisteredID(dlg, item);
- return(text);
- }
-
- void DlgTextSelect(DialogPtr dlg, short item, short start, short end)
- {
- TextHandle text = DlgTextHandle(dlg, item);
- if (text) {
- if (end > TxLength(text))
- end = TxLength(text);
- TxSelect(text, start, end);
- if (FocusWindow() == dlg)
- FocusSet(text);
- else
- WinFocusSet(dlg, text);
- }
- else
- SelIText(dlg, item, start, end);
- }
-
- void DlgTextSelectAll(DialogPtr dlg, short item)
- {
- DlgTextSelect(dlg, item, 0, SHRT_MAX);
- }
-
- /* set the text of the edit or static text item */
- void DlgTextSet(DialogPtr dlg, short item, const CStr255 str)
- {
- CStr255 tmpstr;
- TextHandle text = NULL;
-
- require(DlgTypeText(DlgType(dlg, item)));
- require(StrValid(str, sizeof(CStr255)));
- DlgText(dlg, item, tmpstr);
- if (strcmp(str, tmpstr) != 0) {
- text = DlgTextHandle(dlg, item);
- if (text) {
- TxSetText(text, str, strlen(str));
- TxUpdate(text);
- }
- else {
- short kind = WinKind(dlg);
- WinKindSet(dlg, dialogKind);
- SetIText(DlgHandle(dlg, item), c2pstrcpy((StringPtr) tmpstr, str));
- WinKindSet(dlg, kind);
- }
- }
- }
-
- /* return the text of the edit or static text item */
- void DlgText(DialogPtr dlg, short item, CStr255 str)
- {
- TextHandle text = NULL;
-
- require(DlgValid(dlg));
- require(DlgTypeText(DlgType(dlg, item)));
- text = DlgTextHandle(dlg, item);
- if (text)
- str[TxGetText(text, str, sizeof(CStr255)-1)] = 0;
- else {
- GetIText(DlgHandle(dlg, item), (StringPtr) str);
- p2cstr((StringPtr) str);
- }
- }
-
- /* get the first 'len' characters of the text item */
- void DlgTextLen(DialogPtr dlg, short item, char *str, short len)
- {
- CStr255 tmpstr;
-
- require(len > 0);
- DlgText(dlg, item, tmpstr);
- strncpy(str, tmpstr, len-1);
- str[len-1] = 0;
- }
-
- /* set the edit or static text item to the number */
- void DlgNumSet(DialogPtr dlg, short item, long num)
- {
- Str255 str;
-
- NumToString(num, str);
- DlgTextSet(dlg, item, p2cstr(str));
- }
-
- /* return the numeric value of the edit or static text item */
- long DlgNum(DialogPtr dlg, short item)
- {
- CStr255 str;
- long result;
-
- DlgText(dlg, item, str);
- StringToNum(c2pstr(str), &result);
- return(result);
- }
-
- /* set the edit or static text item to the floating point number */
- void DlgFloatSet(DialogPtr dlg, short item, float num, short precision)
- {
- CStr31 str;
-
- FloatToString(num, str, precision);
- DlgTextSet(dlg, item, str);
- }
-
- /* return the floating point value of the edit or static text item */
- float DlgFloat(DialogPtr dlg, short item)
- {
- CStr31 str;
-
- DlgTextLen(dlg, item, str, sizeof(CStr31));
- return(FloatFromString(str));
- }
-
- /*----------------------------------------------------------------------------*/
- /* clicked item */
- /*----------------------------------------------------------------------------*/
-
- void DlgClick(DialogPtr dlg, short item)
- {
- WinExtraPtr(dlg)->item = item;
- }
-
- short DlgClicked(DialogPtr dlg)
- {
- return(WinExtraPtr(dlg)->item);
- }
-
- /*----------------------------------------------------------------------------*/
- /* positioning dialogs */
- /*----------------------------------------------------------------------------*/
-
- /* Position dialog on screen at the default location (centered horizontally, one
- third from the top vertically). */
- void DlgPosition(DialogPtr dlg)
- {
- WinPosition(dlg, 2, 3);
- }
-
- /* center the dialog */
- void DlgCenter(DialogPtr dlg)
- {
- WinPosition(dlg, 2, 2);
- }
-
- /* Place in 'pt' the coordinates for the top left corner of the
- dialog so that the dialog would be centered horizontally and one third
- from the top of the screen. Normally, you'd use DlgBegin() and DlgPosition(),
- and then simply call WinShow() for the dialog. Occassionally, though,
- you'll need to position a dialog whose template specifies
- that it is visible, or which is created and run by the ToolBox,
- such as a Standard File dialog: use this function for such cases. */
- void DlgPositionPoint(short id, Point *pt)
- {
- Rect bounds = (**(DialogTHndl) ResGet('DLOG', id)).boundsRect;
- RectPositionInScreen(&bounds, 2, 3, pt);
- }
-
- /*----------------------------------------------------------------------------*/
- /* getting and disposing of dialogs */
- /*----------------------------------------------------------------------------*/
-
- /* uninitialize the dialog */
- static void DlgUninitialize(DialogPtr dlg)
- {
- short i;
-
- if (dlg) {
- for (i = 1; i <= DlgNItems(dlg); i++) {
- EventObjectType object = WinRegisteredID(dlg, i);
- if (object) {
- if (DlgTypeText(DlgType(dlg, i)))
- TxEnd(object);
- else if (DlgTypeCtl(DlgType(dlg, i)))
- CtlUninitialize(object);
- }
- }
- if (WinIsModal(dlg))
- WinUnregister(dlg, dlg);
- WinUninitialize(dlg);
- }
- }
-
- /* initialize the dialog */
- static void DlgInitialize(DialogPtr dlg)
- {
- short i;
- Boolean first;
-
- TRY {
- if (WinIsModal(dlg)) {
- DlgModalInit(dlg);
- WinRegister(dlg, dlg, DlgModalEventTable());
- }
- first = true;
- for (i = 1; i <= DlgNItems(dlg); i++) {
- if (DlgTypeEditText(DlgType(dlg, i))) {
- TextHandle text = NULL;
- Rect bounds;
- Str255 str;
- DlgBox(dlg, i, &bounds);
- InsetRect(&bounds, -(TX_MARGIN + FRAME_WIDTH),
- -(TX_MARGIN + FRAME_WIDTH));
- text = TxBeginEdit(dlg, &bounds);
- WinRegisterID(dlg, text, i);
- GetIText(DlgHandle(dlg, i), str);
- TxSetText(text, (char *) str + 1, *str);
- TxAutoViewSet(text, true);
- HideDItem(dlg, i);
- if (first) {
- DlgTextSelectAll(dlg, i);
- first = false;
- }
- }
- else if (DlgTypeCtl(DlgType(dlg, i))) {
- CtlInitialize(DlgCtl(dlg, i));
- WinRegisterID(dlg, DlgCtl(dlg, i), i);
- }
- }
- } CATCH {
- DlgUninitialize(dlg);
- } ENDTRY;
- }
-
- /* create an invisible dialog from the template */
- static DialogPtr DlgBeginTemplate(DialogTemplate *tmpl)
- {
- volatile DialogPtr dlg = NULL;
- volatile Handle ditl = NULL;
- WindowLayerType layer = 0;
- WindowPtr behind = NULL;
-
- require(RectValid(&tmpl->boundsRect));
- TRY {
- behind = WinAdjustTemplate((WindowTemplate *) tmpl, &layer);
- ditl = HandleCopy(ResGet('DITL', tmpl->itemsID)); /* copy for NewDialog */
- MemCheck(sizeof(DialogRecord));
- if (MacHasColor()) {
- dlg = NewCDialog(NULL, &tmpl->boundsRect, tmpl->title, false,
- tmpl->procID, behind, tmpl->goAwayFlag, tmpl->refCon, ditl);
- }
- else {
- dlg = NewDialog(NULL, &tmpl->boundsRect, tmpl->title, false,
- tmpl->procID, behind, tmpl->goAwayFlag, tmpl->refCon, ditl);
- }
- FailNIL(dlg);
- WinInitialize(dlg, layer);
- DlgInitialize(dlg);
- DlgPosition(dlg);
- } CATCH {
- if (dlg)
- DisposeDialog(dlg);
- HandleEnd(ditl);
- } ENDTRY;
- ensure(DlgValid(dlg) && ! WinVisible(dlg));
- return(dlg);
- }
-
- /* get a new alert */
- static DialogPtr DlgOpenALRT(short id)
- {
- AlertTemplate **alrt = NULL;
- DialogTemplate tmpl;
-
- alrt = (AlertTemplate **) ResGet('ALRT', id);
- tmpl.boundsRect = (**alrt).boundsRect;
- tmpl.procID = dBoxProc;
- tmpl.visible = false;
- tmpl.filler1 = 0;
- tmpl.goAwayFlag = false;
- tmpl.filler2 = 0;
- tmpl.refCon = 0;
- tmpl.itemsID = (**alrt).itemsID;
- tmpl.title[0] = 0;
- return(DlgBeginTemplate(&tmpl));
- }
-
- /* get a new dialog */
- static DialogPtr DlgOpenDLOG(short id)
- {
- DialogTemplate tmpl;
-
- ResPtr('DLOG', id, &tmpl, sizeof(DialogTemplate));
- return(DlgBeginTemplate(&tmpl));
- }
-
- /* This is like GetNewDialog except the same function is used to create
- dialogs and alerts, more error checking is done, and you can't pass
- a pointer to your own storage. The dialog is first searched for in the
- list of preloaded dialogs, and if not found there then a pointer to the
- dialog is allocated. The dialog is always created in an invisible window.
- You must use DlgEnd to dispose of the dialog. The 'type' parameter
- should be either 'DLOG' or 'ALRT'. */
- static DialogPtr DlgBeginType(ResType type, short id)
- {
- short i = 0;
- volatile DialogPtr dlg = NULL;
-
- require(type == 'DLOG' || type == 'ALRT');
- TRY {
- /* search for dialog in list of preloaded dialogs */
- for (i = 0; i < DLG_PRELOAD_MAX; i++) {
- if (gPreload[i].type == type && id == gPreload[i].id) {
- if (! gPreload[i].open) {
- dlg = gPreload[i].dlg;
- gPreload[i].open = true;
- /* fix window order, since other windows have been created
- since this window was displayed */
- WinLayerSet(dlg, WinLayer(dlg));
- }
- break;
- }
- }
- if (! dlg) {
- /* open a new dialog */
- if (type == 'ALRT')
- dlg = DlgOpenALRT(id);
- else
- dlg = DlgOpenDLOG(id);
- }
- } CATCH {
- DlgEnd(dlg);
- } ENDTRY;
- ensure(DlgValid(dlg));
- return(dlg);
- }
-
- /* see description of DlgBeginType */
- DialogPtr DlgBeginAlert(short id)
- {
- return(DlgBeginType('ALRT', id));
- }
-
- /* see description of DlgBeginType */
- DialogPtr DlgBegin(short id)
- {
- return(DlgBeginType('DLOG', id));
- }
-
- /* Dispose of the dialog; this is analogous to the ToolBox routine
- DisposeDialog. */
- void DlgEnd(DialogPtr dlg)
- {
- short i = 0;
-
- if (dlg) {
- WinHide(dlg);
- /* search for dialog in list of preloaded dialogs */
- for (i = 0; i < DLG_PRELOAD_MAX; i++) {
- if (dlg == gPreload[i].dlg) {
- /* dialog was preloaded, so keep it loaded */
- gPreload[i].open = false;
- dlg = NULL;
- }
- }
- /* dispose of dialog if it wasn't preloaded */
- if (dlg) {
- DlgUninitialize(dlg);
- DisposeDialog(dlg);
- dlg = NULL;
- }
- }
- ensure(! DlgValid(dlg));
- }
-
- /*----------------------------------------------------------------------------*/
- /* preloading dialogs */
- /*----------------------------------------------------------------------------*/
-
- /* Create the dialog and add it to the list of preloaded dialogs. If the list
- is full or if the dialog couldn't be created then NULL is returned. */
- DialogPtr DlgPreload(ResType type, short id)
- {
- volatile DialogPtr dlg = NULL;
- short i = 0;
-
- TRY {
- for (i = 0; i < DLG_PRELOAD_MAX; i++) {
- if (! gPreload[i].dlg) {
- dlg = DlgBeginType(type, id);
- gPreload[i].id = id;
- gPreload[i].type = type;
- gPreload[i].open = false;
- gPreload[i].dlg = dlg;
- break;
- }
- }
- } CATCH {
- DlgEnd(dlg);
- } ENDTRY;
- }
-
- /* unload a preloaded dialog */
- void DlgUnload(ResType type, short id)
- {
- short i = 0;
-
- for (i = 0; i < DLG_PRELOAD_MAX; i++) {
- if (gPreload[i].type == type && gPreload[i].id == id) {
- DlgEnd(gPreload[i].dlg);
- memclr(&gPreload[i], sizeof(gPreload[i]));
- break;
- }
- }
- }
-